using System.Collections;
using Examples;
using UnityEngine;
using cframework_coroutineutil;
using System.Linq;

public class ExampleWaitAny : ExampleBase
{
    private void Start()
    {
        StartCoroutine(ExampleCoroutine());
    }
    private IEnumerator ExampleCoroutine()
    {        
        yield return StartCoroutine(WaitAnyExampleOne());
        Debug.Log(string.Empty);
        //yield return StartCoroutine(WaitAnyExampleTwo());
    }
    
    private IEnumerator WaitAnyExampleOne()
    {
        Debug.Log("WaitAny example #1 started");
        var e = new WaitAny(WaitOne(), WaitTwo(), WaitThree());
        yield return e;
        Debug.Log("WaitAny example #1 ended " + string.Join(",", e.results.ToList().ConvertAll(a => a.finished)));
        //Debug.Log("WaitAny example # ended");
        //yield return new WaitForSeconds(3.0f);
    }
    
    //private IEnumerator WaitAnyExampleTwo()
    //{
    //    Debug.Log("WaitAny example #2 started");
    //    yield return this.WaitAny(WaitOne(), WaitTwo(), WaitThree());
    //    Debug.Log("WaitAny example #2 ended");
    //    yield return new WaitForSeconds(3.0f);
    //}

}

